X** This software is Copyright (c) 1991 by Daniel Weaver.
X**
X** Permission is hereby granted to copy, distribute or otherwise
X** use any part of this package as long as you do not try to make
X** money from it or pretend that you wrote it. This copyright
X** notice must be maintained in any copy made.
X**
X** Use of this software constitutes acceptance for use in an AS IS
X** condition. There are NO warranties with regard to this software.
X** In no event shall the author be liable for any damages whatsoever
X** arising out of or in connection with the use or performance of this
X** software. Any use of this software is at the user's own risk.
X**
X** If you make modifications to this software that you feel
X** increases it usefulness for the rest of the community, please
X** email the changes, enhancements, bug fixes as well as any and
X** all ideas to me. This software is going to be maintained and
X** enhanced as deemed necessary by the community.
X*/
X/* this module tests boolian flags and terminal modes */
X
X#include "curses.h"
X#include "ted.h"
X
Xstatic void
Xuprint(s)
Xchar *s;
X { /* underline string for (ul) test */
X if (s)
X while (*s) {
X put_str("_\b");
X putchp(*s++);
X }
X }
X
X
X/* Note: uprint() sends underscore back-space character, and
X ucprint() sends character back-space underscore. */
X
Xstatic void
Xucprint(s)
Xchar *s;
X { /* underline string for (uc) test */
X if (s)
X while (*s) {
X putchp(*s++);
X putchp('\b');
X putp(underline_char);
X }
X }
X
X
Xstatic void
Xsubtest_tbc()
X { /* test clear tabs (tbc) */
X int i;
X
X put_clear();
X putp(clear_all_tabs);
X ptext("Clear tabs (tbc)");
X go_home();
X put_crlf(); putchp('\t'); putchp('T');
X go_home();
X put_newlines(2);
X for (i = 1; i < columns; i++) {
X putchp('.');
X }
X putchp('T'); go_home();
X ptext("\n\n\nDone. (tbc)");
X }
X
X
Xstatic void
Xsubtest_hts()
X { /* set tabs with (hts), also (xt) glitch */
X int i, tabat;
X
X put_clear();
X tabat = init_tabs;
X if (set_tab)
X {
X ptext("Tabs set with (hts)");
X put_crlf();
X for (i = 1; i < columns; i++) {
X if (i % 8 == 1) putp(set_tab);
X putchp(' ');
X }
X tabat = 8;
X }
X else
X {
X ptext("(hts) not defined. The following tabs are set:");
X }
X go_home();
X put_newlines(2);
X if (tabat <= 0) tabat = 8;
X for (i = tabat; i < columns; i += tabat) {
X putchp('\t'); putchp('T');
X }
X go_home();
X put_newlines(3);
X for (i = 1; i < columns; i++) {
X putchp('.');
X }
X go_home();
X put_newlines(3);
X for (i = tabat; i < columns; i += tabat) {
X putchp('\t'); putchp('T');
X }
X go_home();
X put_newlines(4);
X putchp('.');
X for (i = 2; i < columns; i++) {
X if (i % tabat == 1) putchp('T');
X else putchp('.');
X }
X go_home();
X put_newlines(5);
X ptextln("The last two lines should be the same.");
X
X#if defined(SVR3) || defined(XENIX)
X if (!over_strike && (init_tabs > 0 || set_tab))
X {
X ptextln("\nDestructive tab test");
X ptext("(xt) should not "); put_cr();
X ptext("(xt) should");
X while (char_count < 16) {
X if (translate_mode && tab) putp(tab);
X else putp(TM_tab);
X char_count = ((char_count / tabat) + 1) * tabat;
X }
X putln("be set.");
X sprintf(temp, "(xt) is %s in the data base.",
X dest_tabs_magic_smso ? "true": "false");
X ptextln(temp);
X }
X#endif
X }
X
Xstatic void
Xsubtest_cbt()
X { /* test back tab (cbt) */
X int i;
X
X if (back_tab)
X {
X put_clear();
X ptext("Back tabs (cbt)");
X go_home();
X put_crlf();
X for (i = 1; i < columns; i++) {
X putchp(' ');
X }
X for (i = 0; i < columns; i += 8) {
X putp(back_tab); putchp('T');
X putp(back_tab);
X }
X go_home();
X put_newlines(2);
X for (i = 1; i < columns; i++) {
X if (i % 8 == 1) putchp('T');
X else putchp('.');
X }
X go_home();
X put_newlines(4);
X }
X else
X {
X if (init_tabs <= 0 && !set_tab)
X {
X /* setupterm() resets (cbt) if both (it) and (hts) are
X missing. */
X ptextln("(it) and (hts) missing... (cbt) back tab not tested!");
X }
X else ptextln("(cbt) back tab not present");
X }
X }
X
X
Xstatic void
Xtest_os_set()
X { /* test (am) (smam) (rmam) (xenl) on overstrike terminals */
X int i, j;
X
X#if defined(SVR3) || defined(XENIX)
X if (exit_am_mode && can_go_home)
X {
X go_home();
X putp(exit_am_mode);
X ptext("\n(rmam) will reset (am)");
X go_home();
X for (j = 0; j < columns; j++) put_this(' ');
X ptext("(rmam) will not reset (am)");
X }
X else ptext("(rmam) not present.");
X
X if (enter_am_mode && can_go_home)
X {
X go_home();
X putp(enter_am_mode);
X ptext("\n\n\n(smam) will ");
X i = char_count;
X ptext("not set (am)");
X go_home();
X put_newlines(2);
X for (j = -i; j < columns; j++) put_this(' ');
X put_str("@@@");
X }
X else ptext("\n\n(smam) not present.");
X#endif
X
X if (can_go_home)
X {
X go_home();
X ptext("\n\n\n\n\n(am) should ");
X i = char_count;
X ptext("not be set");
X go_home();
X put_newlines(4);
X for (j = -i; j < columns; j++) put_this(' ');
X put_str("@@@");
X go_home();
X put_newlines(6);
X }
X else put_crlf();
X sprintf(temp, "(am) is %s in the data base",
X auto_right_margin ? "true" : "false");
X ptextln(temp);
X
X ptext("\n(bw) should ");
X i = char_count;
X ptextln("not be set.");
X for (j = i; j < columns; j++) put_str("\b");
X put_str("@@@");
X put_crlf();
X sprintf(temp, "(bw) is %s in the data base",
X auto_left_margin ? "true" : "false");
X ptextln(temp);
X }
X
X
Xstatic void
Xsubtest_os_xenl()
X { /* test (xenl) on overstrike terminals */
X int i, j, k;
X
X if (can_go_home && can_clear_screen)
X { /* (xenl) test */
X put_clear();
X /* this test must be done in raw mode. Otherwise UNIX
X will translate CR to CRLF. */
X if (stty_query(TTY_OUT_TRANS)) tty_raw(1, char_mask);
X ptext("\nreset (xenl). Does ");
X i = char_count;
X put_str("not ignore CR, does ");
X k = char_count;
X put_str("not ignore LF");
X go_home();
X for (j = 0; j < columns; j++) put_this(' ');
X put_cr();
X for (j = 0; j < i; j++) putchp(' ');
X put_str("@@@\n@@");
X go_home();
X for (j = 0; j < columns; j++) put_this(' ');
X put_lf();
X for (j = 0; j < k; j++) putchp(' ');
X put_str("@@@\r@@");
X tty_set();
X go_home();
X put_newlines(4);
X }
X else ptextln("\n(xenl) not tested, (clear) (cup) or (home) missing");
X sprintf(temp, "(xenl) is %s in the data base",
X eat_newline_glitch ? "true" : "false");
X ptextln(temp);
X }
X
X
Xstatic void
Xtest_os_reset()
X { /* test (am) (smam) (rmam) (xenl) on non-overstrike terminals */
X int i, j;
X
X#if defined(SVR3) || defined(XENIX)
X if (exit_am_mode && can_go_home)
X {
X go_home();
X putp(exit_am_mode);
X ptext("\n(rmam) will reset (am)");
X go_home();
X for (j = 0; j < columns; j++) put_this(' ');
X ptext("(rmam) will not reset (am) ");
X go_home();
X put_str(" ");
X }
X else ptext("(rmam) not present.");
X
X if (enter_am_mode && can_go_home)
X {
X go_home();
X putp(enter_am_mode);
X ptext("\n\n\n(smam) will not set (am)");
X go_home();
X put_newlines(2);
X for (j = 0; j < columns; j++) put_this(' ');
X ptext("(smam) will set (am) ");
X go_home();
X put_str("\n\n ");
X }
X else ptext("\n\n(smam) not present.");
X#endif
X
X if (can_go_home)
X {
X go_home();
X ptext("\n\n\n\n\n(am) should not be set");
X go_home();
X put_newlines(4);
X for (j = 0; j < columns; j++) put_this(' ');
X ptext("(am) should be set ");
X go_home();
X put_str("\n\n\n\n \n\n");
X }
X else put_crlf();
X sprintf(temp, "(am) is %s in the data base",
X auto_right_margin ? "true" : "false");
X ptextln(temp);
X
X /* (ul) is used only if (os) is reset */
X sprintf(temp, "\n(ul) is %s in the data base",
X transparent_underline ? "true" : "false");
X ptextln(temp);
X sprintf(temp, "This text should %sbe underlined.",
X transparent_underline ? "" : "not ");
X uprint(temp);
X put_newlines(2);
X
X if (underline_char)
X {
X ptextln("Test underline character (uc)");
X ucprint("This text should be underlined.");
X put_newlines(2);
X }
X else
X if (!enter_underline_mode)
X ptextln("(uc) underline character, is not defined\n");
X
X ptextln("(bw) should not be set.");
X for (i = 12; i < columns; i++) put_str("\b");
X if (delete_character)
X for (i = 0; i < 4; i++) putp(delete_character);
X else put_str(" ");
X put_crlf();
X sprintf(temp, "(bw) is %s in the data base",
X auto_left_margin ? "true" : "false");
X ptextln(temp);
X }
X
X
Xstatic void
Xsubtest_xenl()
X { /* test (xenl) when (os) is reset */
X int j;
X
X if (can_go_home)
X { /* (xenl) test */
X put_clear();
X /* this test must be done in raw mode. Otherwise UNIX
X will translate CR to CRLF. */
X if (stty_query(TTY_OUT_TRANS)) tty_raw(1, char_mask);
X for (j = 0; j < columns; j++) put_this(' ');
X put_cr();
X ptext("(xenl) should be set. Does not ignore CR");
X go_home();
X put_crlf();
X for (j = 0; j < columns; j++) put_this(' ');
X put_lf(); /* test (cud1) */
X ptext("(xenl) should be set. Ignores (cud1)");
X go_home();
X put_newlines(3);
X if (scroll_forward && cursor_down &&
X strcmp(scroll_forward, cursor_down))
X {
X for (j = 0; j < columns; j++) put_this(' ');
X put_ind(); /* test (ind) */
X ptext("(xenl) should be set. Ignores (ind)");
X go_home();
X put_newlines(5);
X }
X tty_set();
X ptextln("If the above lines are blank then (xenl) should be false");
X }
X else ptextln("(xenl) not tested, (clear) (cup) or (home) missing");
X sprintf(temp, "(xenl) is %s in the data base",
X eat_newline_glitch ? "true" : "false");
X ptextln(temp);
X }
X
X
Xtest_mode()
X {
X int i, j;
X char *s;
X
X new_test(3);
X if (run_mode("(os)"))
X do {
X ptext("\n(os) should be true, not false."); put_cr();
X ptextln("(os) should be false.");
X sprintf(temp, "(os) is %s in the data base",
X over_strike ? "true" : "false");
X ptextln(temp);
X } while (repeat_test(FALSE));
X
X if (run_mode("(smam)(rmam)(ul)(uc)(am)(bw)"))
X do {
X put_clear();
X if (over_strike) test_os_set();
X else test_os_reset();
X } while (repeat_test(FALSE));
X
X if (run_mode("(xenl)(eo)(xmc)(xhp)"))
X do {
X if (over_strike) subtest_os_xenl();
X else subtest_xenl();
X
X if (transparent_underline || over_strike || underline_char)
X { /* test (eo) */
X sprintf(temp, "\n(eo) is %s in the data base",
X erase_overstrike ? "true" : "false");
X ptextln(temp);
X ptext("(eo) should ");
X if (underline_char) ucprint("not");
X else uprint("not");
X put_cr();
X ptextln("(eo) should be set");
X }
X
X if (enter_standout_mode)
X {
X sprintf(temp, "\n(xmc) is %d", magic_cookie_glitch);
X ptextln(temp);
X j = magic_cookie_glitch * 8;
X for (i = 0; i < j; i++) put_str(" ");
X ptextln(" These two lines should line up.");
X if (j > 0) char_count += j;
X for (i = 0; i < 4; i++) {
X put_mode(enter_standout_mode);
X putchp(' ');
X put_mode(exit_standout_mode);
X putchp(' ');
X }
X ptextln("These two lines should line up.");
X
X /* test (xhp) */
X put_crlf(); put_mode(enter_standout_mode);
X put_str("Stand out"); put_mode(exit_standout_mode);
X put_cr();
X ptextln("If any part of this line is standout then (xhp) should be set.");
X sprintf(temp, "(xhp) is %s in the data base",
X ceol_standout_glitch ? "true" : "false");
X ptextln(temp);
X }
X } while (repeat_test(FALSE));
X
X if (run_test(cursor_address,
X "(mir) and (msgr) not tested because (cup) is missing", FALSE))
X do {
X put_clear();
X if (enter_insert_mode != (char *)0 &
X exit_insert_mode != (char *)0)
X {
X ptextln("If the block of X's are square then (mir) should be set. (smir) (rmir) (cup)");
X i = line_count;
X put_str("\nXXX\nXXX\nXXX\nXXX");
X putp(enter_insert_mode);
X s = tcup(cursor_address, i + 1, 0);
X tputs(s, lines, putch);
X putchp('x');
X s = tcup(cursor_address, i + 2, 1);
X tputs(s, lines, putch);
X putchp('x');
X s = tcup(cursor_address, i + 3, 2);
X tputs(s, lines, putch);
X putchp('x');
X s = tcup(cursor_address, i + 4, 3);
X tputs(s, lines, putch);
X putchp('x');
X putp(exit_insert_mode);
X put_crlf();
X }
X else ptextln("(smir) (rmir) not present. (mir) not tested.");
X if ((enter_standout_mode && exit_standout_mode) ||
X (enter_alt_charset_mode && exit_alt_charset_mode))
X {
X put_crlf();
X ptext("If you see a diagonal line of standout X's then (msgr) should be set, if any of the blanks are standout then (msgr) should be reset. (smacs) (rmacs) (cup)");
X i = line_count + 1;
X tputs(tcup(cursor_address, i, 0), lines, putch);
X put_mode(enter_alt_charset_mode);
X put_crlf();
X /* some versions of the wy-120 can not clear lines or
X screen when in alt charset mode. If (el) and (ed)
X are defined then I can test them. If they are not
X defined then they can not break (msgr) */
X putp(clr_eos);
X putp(clr_eol);
X put_mode(exit_alt_charset_mode);
X put_mode(enter_standout_mode);
X putchp('X');
X tputs(tcup(cursor_address, i + 2, 1), lines, putch);
X putchp('X');
X tputs(tcup(cursor_address, i + 3, 2), lines, putch);
X putchp('X');
X tputs(tcup(cursor_address, i + 4, 3), lines, putch);
X putchp('X');
X put_mode(exit_standout_mode);
X put_crlf();
X putp(clr_eos); /* OK if missing */
X put_crlf();
X }
X else ptextln("(smso) (rmso) (smacs) (rmacs) not present. (msgr) not tested.");
X sprintf(temp, "(mir) is %s and (msgr) is %s in the data base",
X move_insert_mode ? "true" : "false",
X move_standout_mode ? "true" : "false");
X ptextln(temp);
X } while (repeat_test(FALSE));
X
X if (run_test(clear_all_tabs,
X "Clear all tabs (tbc) not defined.", TRUE))
X do {
X subtest_tbc();
X } while (repeat_test(FALSE));
X
X if (run_mode("(hts)(xt)"))
X do {
X subtest_hts();
X } while (repeat_test(FALSE));
X
X if (run_mode("(cbt)(in)"))
X do {
X subtest_cbt();
X
X if (enter_insert_mode && exit_insert_mode)
X { /* test (in) */
X ptextln("\nTesting (in) with (smir) and (rmir)");
X putln("\tIf these two lines line up ...");
X put_str("\tIf these two lines line up ...");
X put_cr();
X putp(enter_insert_mode);
X putchp(' ');
X putp(exit_insert_mode);
X ptext("\nthen (in) should be set. ");
X sprintf(temp,
X "(in) is %s in the data base.",
X insert_null_glitch ? "true" : "false");
X ptextln(temp);
X }
X } while (repeat_test(FALSE));
X
X if (run_mode("(da)(db)")
X && can_clear_screen && scroll_reverse && scroll_forward)
X do { /* test (da) and (db) */
X put_clear();
X if (scroll_reverse) ptext("(da) should be set\r");
X move_to(0, 0, lines - 1, 0, 3);
X if (scroll_forward) ptext("(db) should be set\r");
X putp(scroll_forward);
X move_to(lines - 1, 0, 0, 0, 3);
X putp(scroll_reverse);
X putp(scroll_reverse);
X move_to(0, 0, lines - 1, 0, 3);
X putp(scroll_forward);
X move_to(lines - 1, 0, 0, 0, 3);
X ptextln("\n\n\n\n\nIf the top line is blank then (da) should be false.");
X ptextln("If the bottom line is blank then (db) should be false.");
X sprintf(temp, "\n(da) is %s, and (db) is %s, in the data base.",
X memory_above ? "true" : "false",
X memory_below ? "true" : "false");
X ptextln(temp);
X line_count = lines;
X } while (repeat_test(FALSE));
X }
END_OF_FILE
if test 19417 -ne `wc -c <'modes.c'`; then
echo shar: \"'modes.c'\" unpacked with wrong size!
fi
# end of 'modes.c'
fi
if test -f 'output.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'output.c'\"